package com.ian.event;

import org.springframework.context.event.EventListener;
import org.springframework.security.authentication.event.AbstractAuthenticationFailureEvent;
import org.springframework.security.authentication.event.AuthenticationSuccessEvent;
import org.springframework.stereotype.Component;

/**
 * @author Witt
 * @version 1.0.0
 * @date 2022/5/2
 */
@Component
public class AuthenticationEvents {
    @EventListener
    public void onSuccess(AuthenticationSuccessEvent success) {
        System.out.format("AuthenticationSuccessEvent: success! The authentication is: %s%n", success.getAuthentication());
    }

    @EventListener
    public void onFailure(AbstractAuthenticationFailureEvent failures) {
        System.err.format("AbstractAuthenticationFailureEvent: failures! The exception is: %s%n", failures.getException());
    }
}
